package com.zbkj.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.coupon.CouponProduct;
import com.zbkj.common.model.member.PaidMemberCardProduct;
import com.zbkj.service.dao.zfbadminregion.PaidMemberCardProductDao;
import com.zbkj.service.service.PaidMemberCardProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PaidMemberCardProductServiceImpl extends ServiceImpl<PaidMemberCardProductDao, PaidMemberCardProduct> implements PaidMemberCardProductService {
    @Resource
    private PaidMemberCardProductDao paidMemberCardProductDao;
    /**
     * 通过优惠券id查询列表
     * @param cid 优惠券ID
     * @return List
     */
    @Override
    public List<PaidMemberCardProduct> findByCid(Integer cid) {
        LambdaQueryWrapper<PaidMemberCardProduct> lqw = Wrappers.lambdaQuery();
        lqw.eq(PaidMemberCardProduct::getCardId, cid);
        return paidMemberCardProductDao.selectList(lqw);
    }

    /**
     * 通过优惠券id删除
     * @param cid 优惠券ID
     * @return Boolean
     */
    @Override
    public Boolean deleteByCid(Integer cid) {
        LambdaUpdateWrapper<PaidMemberCardProduct> wrapper = Wrappers.lambdaUpdate();
        wrapper.eq(PaidMemberCardProduct::getCardId, cid);
        return paidMemberCardProductDao.delete(wrapper) > 0;
    }
}
